package com.atguigu.principle.Liskov;

public class Liskov2 {
    public static void main(String[] args) {
        AA a=new AA();
        System.out.println(a.fun1(44,30));
        BB b=new BB();
        System.out.println(b.fun1(77,44));
        System.out.println(  b.fun2(11,12));
    }
}

/**
 * 里氏替换原则：将两个类共有方法提取出来放到base类中。base类为基类，不会轻易改变方法
 */
class Base{
    public int  fun1(int a,int b){
        return a-b;
    }
}

class AA extends Base{
    @Override
    public int fun1(int a, int b) {
        return super.fun1(a, b);
    }
}

class BB extends Base{
    @Override
    public int fun1(int a, int b) {
        return new A().fun1(a, b);
    }

    public int fun2(int a,int b){
        return a+b;
    }
}
